package com.aaa.service;

import com.aaa.dao.TbUserMapper;
import com.aaa.entity.MyPage;

import com.aaa.entity.TbUser;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service  // 业务处理层
public class TbUserServiceImpl implements TbUserService{

    @Autowired
    private TbUserMapper userMapper;

    @Override
    public PageInfo queryByPage(MyPage page) {
        PageHelper.startPage(page.getPage(),page.getLimit());

        return new PageInfo(userMapper.findAll());
    }

    @Override
    public List<TbUser> findAll() {
        return userMapper.selectAll();
    }

//    // DAO
//    @Override
//    public PageInfo findAll(Page page) {
//        // 分页查询   limit  ,limit
//        //
//        PageHelper.startPage(page.getPage(),page.getLimit());
//        List<TbUser> all = userMapper.findAll();
//        PageInfo page1 = new PageInfo(all);
//
//        return page1;
//    }
}
